<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <title>数据后台登录</title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" type="text/css" href="static/css/index.css">
    <script src="static/js/jquery-3.6.0.min.js"></script>
    <!--    <script src="static/js/jquery-3.7.1.min.js"></script>-->
</head>
<body>
<div class="limiter">
    <div class="container-login100">
        <div class="wrap-login100">
            <div class="login100-form-title" style="background-image: url(static/image/bg-01.jpg);">
                <span class="login100-form-title-1">电影数据可分析后台管理</span>
            </div>

            <form class="login100-form validate-form">
                <div class="wrap-input100 validate-input m-b-26" data-validate="用户名不能为空">
                    <span class="label-input100">用户名</span>
                    <input class="input100" id="username" type="text" name="username" placeholder="请输入用户名">
                    <span class="focus-input100"></span>
                </div>

                <div class="wrap-input100 validate-input m-b-18" data-validate="密码不能为空">
                    <span class="label-input100">密&nbsp;&nbsp;&nbsp;码</span>
                    <input class="input100" id="password" type="password" name="password" placeholder="请输入用户名">
                    <span class="focus-input100"></span>
                </div>

                <div class="flex-sb-m w-full p-b-30">
                    <div class="contact100-form-checkbox">
                        <input class="input-checkbox100" id="ckb1" type="checkbox" name="remember-me">
                        <!--<a href="/train/page/face.html">图像处理</a>-->
                        <label class="label-checkbox100" for="ckb1"> <a href="/train/page/face.html">图像处理</a></label>
                    </div>
                </div>

                <div class="container-login100-form-btn">
                    <button id="login" class="login100-form-btn">登 录</button>
                    <button id="smsCodeLogin" class="login100-form-btn">验证码登录</button>
                </div>
            </form>
        </div>
    </div>
</div>

<script>
    document.querySelector('form').addEventListener('submit', function(event) {
        event.preventDefault(); // 阻止浏览器的默认行为  阻止表单提交
    });
    $('#smsCodeLogin').click(function (){
        location.href = "/train/page/SMSLogin.html";
    });
    $('#login').click(function () {

        var username = $('#username').val();
        var password = $('#password').val();

        $.ajax({
            method:"post",
            url:"/train/login",
            data:{
                "username":username,
                "password":password
            },
            success:function (response) {
                var json = JSON.parse(response);
                if(json.code === 200){
                    location.href = "/train/page/success.html";
                }else{
                    alert(json.msg)
                }
            }
        })
    });
</script>

</body>
</html>